const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Product = sequelize.define('Product', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    woo_id: {
        type: DataTypes.INTEGER,
        unique: true,
        allowNull: false
    },
    name: {
        type: DataTypes.STRING,
        allowNull: false
    },
    description: {
        type: DataTypes.TEXT
    },
    price: {
        type: DataTypes.DECIMAL(10, 2),
        allowNull: false
    },
    stock_quantity: {
        type: DataTypes.INTEGER,
        defaultValue: 0
    },
    sku: {
        type: DataTypes.STRING,
        unique: true
    },
    category: {
        type: DataTypes.STRING
    },
    tags: {
        type: DataTypes.TEXT
    },
    images: {
        type: DataTypes.JSON
    },
    ai_description: {
        type: DataTypes.TEXT
    },
    ai_price_suggestion: {
        type: DataTypes.DECIMAL(10, 2)
    },
    sentiment_score: {
        type: DataTypes.FLOAT,
        defaultValue: 0
    },
    last_sync: {
        type: DataTypes.DATE,
        defaultValue: DataTypes.NOW
    },
    is_active: {
        type: DataTypes.BOOLEAN,
        defaultValue: true
    }
});

module.exports = Product;
